//package com.example.springboot_manage.config;
//
//import com.alibaba.druid.util.StringUtils;
//import com.example.springboot_manage.model.Account;
//import com.example.springboot_manage.repository.AccountRepository;
//import com.example.springboot_manage.util.JsonUtil;
//import com.qiniu.util.Json;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Configurable;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.core.ValueOperations;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.springframework.util.CollectionUtils;
//
//import javax.annotation.Resource;
//import java.util.LinkedHashSet;
//import java.util.List;
//import java.util.Set;
//
//@Component
//@Configurable
//@EnableScheduling
//public class DataSaveDB {
//    //每5秒执行一次
//    @Scheduled(cron = "*/10 * *  * * * ")
//    public void saveDataToDB() {
//        System.out.println("run .....");
//    }
//
//    @Autowired
//    private RedisTemplate redisTemplate;
//    @Value("${admin.info}")
//    private String adminInfo;
//    @Autowired
//    private AccountRepository accountRepository;
//
//    //每10秒执行一次，真实项目当中，我们可以把定时器的执行计划时间设置长一点
//    //比如说每天晚上凌晨2点跑一次。
////    @Scheduled(cron = "*/60 * *  * * * ")
////    public void saveDataToDB2() {
////        ValueOperations<Set,Set> valueOperations = redisTemplate.opsForValue();
////        Set<String> accountJsons = valueOperations.multiGet(adminInfo));
////        if (CollectionUtils.isEmpty(accountJsons)){
////            return;
////        }
////        System.out.println(accountJsons);
////        Set<Account> accounts = new LinkedHashSet<>();
////        for (String accountJson : accountJsons) {
////            accounts.add(JsonUtil.jsonStr2Object(accountJson,Account.class)) ;
////        }
////        System.out.println("++++++++++++++++++++");
////        int flag=0;
////        for (Account account : accounts) {
////            flag = accountRepository.update(account);
////        }
////        System.out.println("++++++++++++++++++++++++++++++++++");
////        if (flag>=1){
////            System.out.println("存取success");
////        }
////        System.out.println("++++++++++++++++++++++++++++++++++");
////        //清除缓存数据
////        redisTemplate.delete(redisTemplate.keys("admin*"));
////
////    }
//}
